#pragma once

#include "Connection.hpp"

enum Code_Type
{
    ACCEPT = 1, // 获取新连接
    STOP        // 终止
};


class PipeAgreement // 管道通讯协议
{
    static const uint32_t default_dist_ip = INADDR_ANY;
    static const uint16_t default_dist_port = 0; 
    static const int default_code=0;//默认操作码
    static const int default_fd=-1;//默认操作码
public:
    PipeAgreement()
        : _code(default_code),
          _dist_port(default_dist_port),
          _dist_ip(default_dist_ip),
          _fd(default_fd)
    {
    }
    int Code()const
    {
        return _code;
    }
    int Fd()const
    {
        return _fd;
    }
    uint16_t DistPort()const
    {
        return _dist_port;
    }
    uint32_t DistIp()const
    {
        return _dist_ip;
    }
    void SetCode(int code)
    {
        _code=code;
    }
    void SetFd(int fd)
    {
        _fd=fd;
    }
    void SetDistPort(uint16_t port)
    {
        _dist_port=port;
    }
    void SetDistIp(uint32_t ip)
    {
        _dist_ip=ip;
    }
    ~PipeAgreement()
    {
    }

private:
    int _code;           // 操作码
    int _fd;             //新连接fd
    uint16_t _dist_port; // 对端主机的port
    uint32_t _dist_ip;   // 对端主机的ip
};